/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jifConfiguraReporteOrden.java
 *
 * Created on 25-sep-2010, 13:54:08
 */

package Reportes;

import Proveedores.jifAdministrarProveedor;
import administracion.helper.Listas;
import administracion.helper.Utiles_MensajesDialogo;
import com.jidesoft.hints.ListDataIntelliHints;
import java.awt.CardLayout;
import java.awt.Frame;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JInternalFrame;
import javax.swing.JList;
import javax.swing.JOptionPane;
import suministros.ejb30.TO.EmpresaTO;
import suministros.ejb30.TO.ParametrosConsultaTO;
import suministros.ejb30.TO.ProveedorTO;
import suministros.ejb30.TO.SuministroTO;
import suministros.ejb30.TO.ZonaTO;

/**
 *
 * @author Luis_Angel
 */
public class jifConfiguraReporteOrden extends javax.swing.JInternalFrame {

    private ParametrosConsultaTO params;
    private ListDataIntelliHints intelliHintsProveedor;
    private ListDataIntelliHints intelliHintsSuministros;
    private int id_tipo_orden;
    private int tipo_reporte =1;
    /** Creates new form jifConfiguraReporteOrden */
    public jifConfiguraReporteOrden() {
        initComponents();
        List empresass = Listas.getEmpresas();
        if(empresass.isEmpty()){
            this.jCheckBox1.setEnabled(false);
        }
         try {
            cargaHintsIndependientes();
        } catch (Exception ex) {
            Logger.getLogger(jifAdministrarProveedor.class.getName()).log(Level.SEVERE, null, ex);
        }
        llenarComboZona();
       // llenarComboAno();
        llenarComboEmpresa();
    }

    private void llenarComboZona() {
        List listaZonas = null;
        List listaZonas_cbo = this.cboBeanBindingZona1.getLista();
        listaZonas_cbo.clear();
        try
        {
          listaZonas = Listas.getZonas();
          this.cboBeanBindingZona1.setLista(listaZonas);
          this.bindingGroup.bind();
          this.jcboZona.updateUI();
          this.jcboZona.setSelectedIndex(-1);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener zonas\n" + ex.getMessage());
          ex.printStackTrace();

        }
   }
      private void llenarComboEmpresa() {
        List empresas = null;
        List listaPaises_cbo = this.cboBeanBindingEmpresa1.getLista();
        listaPaises_cbo.clear();
        try
        {
          if(this.jCheckBox1.isSelected()){
                empresas = Listas.getEmpresas();
            }
            else{
                empresas = Listas.getEmpresaPrincipal();
            }
          this.cboBeanBindingEmpresa1.setLista(empresas);
          this.bindingGroup.bind();
          this.jcbEmpresa.updateUI();
          this.jcbEmpresa.setSelectedIndex(0);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener empresas\n" + ex.getMessage());
          ex.printStackTrace();

        }
      }


   
      
    private void cargaHintsIndependientes() throws Exception {
         this.intelliHintsProveedor = new ListDataIntelliHints(this.jtfRazon,Listas.getProveedores());
         this.intelliHintsSuministros = new ListDataIntelliHints(this.jtfDescSuministro, Listas.getSuministros());
         ((JList) this.intelliHintsSuministros.getDelegateComponent()).setFixedCellWidth(273);
         ((JList) this.intelliHintsProveedor.getDelegateComponent()).setFixedCellWidth(342);
    }
       
     private ParametrosConsultaTO getParametrosConsulta(){
        String zona = null;
        String anio = null;
        String mes = null;
        String ruc = null;
        String nro_licitacion = null;
        String id_empresa= null;
        String fecha_desde=null;
        String fecha_hasta=null;
        String id_suministro=null;
        int tipo_orden;
        if(this.jcbEmpresa.getSelectedIndex()>=0)
             id_empresa = ((EmpresaTO)this.jcbEmpresa.getSelectedItem()).getCodigo();
        if(this.jcboZona.getSelectedIndex()>=0)
             zona =((ZonaTO)this.jcboZona.getSelectedItem()).getId_zona();
        if(jrbCompra.isSelected())
           tipo_orden =  Listas.getTipo_porTablaYCodigo("tipo_Orden", "01").getId_tabla_tipo().intValue();
        else
          tipo_orden =   Listas.getTipo_porTablaYCodigo("tipo_Orden", "02").getId_tabla_tipo().intValue();
       /* if(this.jcboAno.getSelectedIndex()>=0)
             anio = ((AnoTO)this.jcboAno.getSelectedItem()).getAno();
        if(this.jcboMes.getSelectedIndex()>=0)
             mes = ((MesTO)this.jcboMes.getSelectedItem()).getMes();*/
        if(this.jtfRuc.getText().trim().length()>0)
             ruc = this.jtfRuc.getText().trim();
        if(this.jtfCodSuministro.getText().trim().length()>0)
             id_suministro = this.jtfCodSuministro.getText().trim();
        if(!this.jftFechaDesde.getText().trim().equalsIgnoreCase("/  /"))
             fecha_desde = this.jftFechaDesde.getText().trim();
        if(!this.jftFechaHasta.getText().trim().equalsIgnoreCase("/  /"))
             fecha_hasta = this.jftFechaHasta.getText().trim();

            ParametrosConsultaTO parametros = new ParametrosConsultaTO();
            parametros.setAnio(anio);
            parametros.setMes(mes);
            parametros.setId_zona(zona);
            parametros.setRuc_proveedor(ruc);
            parametros.setNro_licitacion(nro_licitacion);
            parametros.setId_empresa(id_empresa);
            parametros.setFecha_inicio(fecha_desde);
            parametros.setFecha_fin(fecha_hasta);
            parametros.setTipo_orden(tipo_orden);
            parametros.setId_suministro(id_suministro);
            return parametros;
        }

      private void buscarRazonSocial()
      {
        ProveedorTO pro;
        if (this.jtfRuc.getText().trim().length() < 1) {
              try { pro = (ProveedorTO)this.intelliHintsProveedor.getSelectedHint();
              } catch (NullPointerException ex) {
                pro = null;
              }
            }
        else {
          pro = Listas.getProveedorcodigo(this.jtfRuc.getText().trim());
        }
        if (pro == null) {
          Utiles_MensajesDialogo.mensajeError("El proveedor no existe!");
          this.jtfRuc.setText("");
          pro = null;
        }
        else {

          this.jtfRazon.setText(pro.getRazon() + " - " + pro.getCodProveedor());
          this.jtfRuc.setText(pro.getCodProveedor());

        }

      }
      
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        cboBeanBindingZona1 = new administracion.BeanBinding.CboBeanBindingZona();
        cboBeanBindingEmpresa1 = new administracion.BeanBinding.CboBeanBindingEmpresa();
        cboBeanBindingTipo1 = new administracion.BeanBinding.CboBeanBindingTipo();
        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jpOperativo = new javax.swing.JPanel();
        carta_blanco = new javax.swing.JPanel();
        carta_licitacion = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jtfLicitacion = new javax.swing.JTextField();
        carta_proveedor = new javax.swing.JPanel();
        jtfRuc = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jtfRazon = new javax.swing.JTextField();
        carta_suministro = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        jtfCodSuministro = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jtfDescSuministro = new javax.swing.JTextField();
        jbBuscar = new javax.swing.JButton();
        jbCancelar = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jrbRequerrimientos1 = new javax.swing.JRadioButton();
        jrbRequerrimientosDetalle1 = new javax.swing.JRadioButton();
        jrbRequerrimientosDetalle2 = new javax.swing.JRadioButton();
        jrbRequerrimientosDetalle4 = new javax.swing.JRadioButton();
        jPanel3 = new javax.swing.JPanel();
        jrbCompra = new javax.swing.JRadioButton();
        jrbServicio = new javax.swing.JRadioButton();
        jPanel1 = new javax.swing.JPanel();
        jftFechaDesde = new javax.swing.JFormattedTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jftFechaHasta = new javax.swing.JFormattedTextField();
        jcboZona = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jCheckBox1 = new javax.swing.JCheckBox();
        jLabel21 = new javax.swing.JLabel();
        jcbEmpresa = new javax.swing.JComboBox();

        setTitle("Reporte de Ordenes");

        jpOperativo.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "CRITERIOS ESPECIFICOS", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), java.awt.Color.blue)); // NOI18N
        jpOperativo.setLayout(new java.awt.CardLayout());

        javax.swing.GroupLayout carta_blancoLayout = new javax.swing.GroupLayout(carta_blanco);
        carta_blanco.setLayout(carta_blancoLayout);
        carta_blancoLayout.setHorizontalGroup(
            carta_blancoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 662, Short.MAX_VALUE)
        );
        carta_blancoLayout.setVerticalGroup(
            carta_blancoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 52, Short.MAX_VALUE)
        );

        jpOperativo.add(carta_blanco, "carta_blanco");

        jLabel5.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel5.setText("NRO LICITACION");

        javax.swing.GroupLayout carta_licitacionLayout = new javax.swing.GroupLayout(carta_licitacion);
        carta_licitacion.setLayout(carta_licitacionLayout);
        carta_licitacionLayout.setHorizontalGroup(
            carta_licitacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(carta_licitacionLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addGap(18, 18, 18)
                .addComponent(jtfLicitacion, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(387, Short.MAX_VALUE))
        );
        carta_licitacionLayout.setVerticalGroup(
            carta_licitacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(carta_licitacionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(carta_licitacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jtfLicitacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(21, Short.MAX_VALUE))
        );

        jpOperativo.add(carta_licitacion, "carta_licitacion");

        jtfRuc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfRucActionPerformed(evt);
            }
        });

        jLabel18.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel18.setText("RUC");

        jLabel9.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/user.png"))); // NOI18N
        jLabel9.setText("PROVEEDOR");

        jtfRazon.setFont(new java.awt.Font("Arial", 0, 12));
        jtfRazon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfRazonActionPerformed(evt);
            }
        });
        jtfRazon.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfRazonKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout carta_proveedorLayout = new javax.swing.GroupLayout(carta_proveedor);
        carta_proveedor.setLayout(carta_proveedorLayout);
        carta_proveedorLayout.setHorizontalGroup(
            carta_proveedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, carta_proveedorLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel18)
                .addGap(18, 18, 18)
                .addComponent(jtfRuc, javax.swing.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE)
                .addComponent(jLabel9)
                .addGap(10, 10, 10)
                .addComponent(jtfRazon, javax.swing.GroupLayout.PREFERRED_SIZE, 342, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        carta_proveedorLayout.setVerticalGroup(
            carta_proveedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(carta_proveedorLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(carta_proveedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(carta_proveedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel18)
                        .addComponent(jtfRuc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(carta_proveedorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel9)
                        .addComponent(jtfRazon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        jpOperativo.add(carta_proveedor, "carta_proveedor");

        jLabel10.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel10.setText("COD. SUMINISTRO");

        jtfCodSuministro.setFont(new java.awt.Font("Arial 12 Simple 12 Simple", 0, 12));
        jtfCodSuministro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfCodSuministroActionPerformed(evt);
            }
        });

        jLabel11.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel11.setText("DESC. SUMINISTRO");

        jtfDescSuministro.setFont(new java.awt.Font("Arial 12 Simple 12 Simple", 0, 12));
        jtfDescSuministro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfDescSuministroActionPerformed(evt);
            }
        });
        jtfDescSuministro.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfDescSuministroKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout carta_suministroLayout = new javax.swing.GroupLayout(carta_suministro);
        carta_suministro.setLayout(carta_suministroLayout);
        carta_suministroLayout.setHorizontalGroup(
            carta_suministroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, carta_suministroLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jtfCodSuministro, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfDescSuministro, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE)
                .addContainerGap())
        );
        carta_suministroLayout.setVerticalGroup(
            carta_suministroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(carta_suministroLayout.createSequentialGroup()
                .addGroup(carta_suministroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jtfCodSuministro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtfDescSuministro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addContainerGap(30, Short.MAX_VALUE))
        );

        jpOperativo.add(carta_suministro, "carta_suministro");

        jbBuscar.setFont(new java.awt.Font("Arial", 1, 12));
        jbBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/format_justify_fill.png"))); // NOI18N
        jbBuscar.setMnemonic('B');
        jbBuscar.setText("VER REPORTE");
        jbBuscar.setToolTipText("Cancelar la Operacion");
        jbBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbBuscarActionPerformed(evt);
            }
        });
        jbBuscar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbBuscarKeyPressed(evt);
            }
        });

        jbCancelar.setFont(new java.awt.Font("Arial", 1, 12));
        jbCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_cancel.png"))); // NOI18N
        jbCancelar.setMnemonic('C');
        jbCancelar.setText("CERRAR");
        jbCancelar.setToolTipText("Cancelar la Operacion");
        jbCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCancelarActionPerformed(evt);
            }
        });
        jbCancelar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbCancelarKeyPressed(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "TIPO DE INFORME", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(0, 0, 255))); // NOI18N

        buttonGroup1.add(jrbRequerrimientos1);
        jrbRequerrimientos1.setSelected(true);
        jrbRequerrimientos1.setText("REPORTE GENERAL DE ORDENES ");
        jrbRequerrimientos1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jrbRequerrimientos1ItemStateChanged(evt);
            }
        });

        buttonGroup1.add(jrbRequerrimientosDetalle1);
        jrbRequerrimientosDetalle1.setText("REPORTE DE ORDENES POR CUENTA CONTABLE");
        jrbRequerrimientosDetalle1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jrbRequerrimientosDetalle1ItemStateChanged(evt);
            }
        });

        buttonGroup1.add(jrbRequerrimientosDetalle2);
        jrbRequerrimientosDetalle2.setText("REPORTE DE ORDENES POR PROVEEDOR");
        jrbRequerrimientosDetalle2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jrbRequerrimientosDetalle2ItemStateChanged(evt);
            }
        });

        buttonGroup1.add(jrbRequerrimientosDetalle4);
        jrbRequerrimientosDetalle4.setText("REPORTE DE ORDENES POR SUMINISTRO");
        jrbRequerrimientosDetalle4.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jrbRequerrimientosDetalle4ItemStateChanged(evt);
            }
        });
        jrbRequerrimientosDetalle4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jrbRequerrimientosDetalle4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jrbRequerrimientos1)
                    .addComponent(jrbRequerrimientosDetalle1))
                .addGap(49, 49, 49)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jrbRequerrimientosDetalle2)
                    .addComponent(jrbRequerrimientosDetalle4))
                .addContainerGap(121, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jrbRequerrimientos1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jrbRequerrimientosDetalle1))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jrbRequerrimientosDetalle2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jrbRequerrimientosDetalle4)))
                .addGap(26, 26, 26))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "TIPO DE ORDEN", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(0, 0, 255))); // NOI18N

        buttonGroup2.add(jrbCompra);
        jrbCompra.setSelected(true);
        jrbCompra.setText("COMPRA");

        buttonGroup2.add(jrbServicio);
        jrbServicio.setText("SERVICIO");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(222, 222, 222)
                .addComponent(jrbCompra)
                .addGap(37, 37, 37)
                .addComponent(jrbServicio)
                .addContainerGap(261, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jrbServicio)
                .addComponent(jrbCompra))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "CRITERIOS GENERALES", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(0, 0, 255))); // NOI18N

        try {
            jftFechaDesde.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jftFechaDesde.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jftFechaDesdeActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel1.setText("Desde");

        jLabel2.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel2.setText("Hasta");

        try {
            jftFechaHasta.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jcboZona.setFont(new java.awt.Font("Arial", 0, 12));

        org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        org.jdesktop.swingbinding.JComboBoxBinding jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingZona1, eLProperty, jcboZona);
        bindingGroup.addBinding(jComboBoxBinding);

        jcboZona.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcboZonaKeyPressed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel4.setText("SUCURSAL");

        jCheckBox1.setFont(new java.awt.Font("Arial", 1, 12));
        jCheckBox1.setText("POR ENCARGO");
        jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox1ActionPerformed(evt);
            }
        });

        jLabel21.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel21.setText("EMPRESA");

        jcbEmpresa.setEnabled(false);

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingEmpresa1, eLProperty, jcbEmpresa);
        bindingGroup.addBinding(jComboBoxBinding);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(45, 45, 45)
                        .addComponent(jCheckBox1)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel21)
                        .addGap(18, 18, 18)
                        .addComponent(jcbEmpresa, 0, 406, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jftFechaDesde, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jftFechaHasta, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 91, Short.MAX_VALUE)
                        .addComponent(jLabel4)
                        .addGap(18, 18, 18)
                        .addComponent(jcboZona, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jCheckBox1)
                    .addComponent(jLabel21)
                    .addComponent(jcbEmpresa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jftFechaDesde, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel1)
                        .addComponent(jftFechaHasta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel2))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jcboZona, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jpOperativo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 674, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(10, 10, 10))
            .addGroup(layout.createSequentialGroup()
                .addGap(174, 174, 174)
                .addComponent(jbBuscar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(248, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jbBuscar, jbCancelar});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpOperativo, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jbBuscar)
                    .addComponent(jbCancelar))
                .addContainerGap(43, Short.MAX_VALUE))
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbBuscarActionPerformed
      
             params = getParametrosConsulta();
             Frame frm = JOptionPane.getFrameForComponent((JInternalFrame)this);
             jdDatosReporteOrden panel = new jdDatosReporteOrden(frm,true);
             panel.setDatos(params,tipo_reporte);
             panel.setTitle("Reporte de Ordenes");
            // panel.setSize(this.getToolkit().getScreenSize());
             panel.setLocationRelativeTo(null);
             
             panel.setVisible(true);
           // int num_ordenes_encontradas = GestionPedidosDelegate.getInstance().getNumeroDeOrdenes(params, id_tipo_orden);
            //panelPaginacion.setTotalResultados(num_ordenes_encontradas);
      
}//GEN-LAST:event_jbBuscarActionPerformed

    private void jbBuscarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbBuscarKeyPressed

      /*  if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jbBuscar.doClick();
        }*/
}//GEN-LAST:event_jbBuscarKeyPressed

    private void jtfRazonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfRazonActionPerformed

        buscarRazonSocial();
        // this.jcboFormaPago.requestFocus();
}//GEN-LAST:event_jtfRazonActionPerformed

    private void jtfRazonKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfRazonKeyPressed
        if (this.jtfRuc.getText().trim().length() > 0)
            this.jtfRuc.setText("");
}//GEN-LAST:event_jtfRazonKeyPressed

    private void jtfRucActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfRucActionPerformed
        if (this.jtfRuc.getText().trim().length() < 1)
            this.jtfRazon.requestFocus();
        else
            buscarRazonSocial();
}//GEN-LAST:event_jtfRucActionPerformed

    private void jbCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCancelarActionPerformed

        this.dispose();
}//GEN-LAST:event_jbCancelarActionPerformed

    private void jbCancelarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbCancelarKeyPressed

}//GEN-LAST:event_jbCancelarKeyPressed

    private void jrbRequerrimientosDetalle4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbRequerrimientosDetalle4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jrbRequerrimientosDetalle4ActionPerformed

    private void jftFechaDesdeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jftFechaDesdeActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jftFechaDesdeActionPerformed

    private void jcboZonaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcboZonaKeyPressed

      /*  if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jcboAno.requestFocus();
        }*/
}//GEN-LAST:event_jcboZonaKeyPressed

    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
        if(this.jCheckBox1.isSelected()){
            this.jcbEmpresa.setEnabled(true);
        } else{
            this.jcbEmpresa.setEnabled(false);
        }
        this.llenarComboEmpresa();
        //this.intelliHintsProyectos.setCompletionList(Listas.obtenerProyectosPorEmpresa(((EmpresaTO)this.jcbEmpresa.getSelectedItem()).getRuc()));
}//GEN-LAST:event_jCheckBox1ActionPerformed

    private void jrbRequerrimientosDetalle2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jrbRequerrimientosDetalle2ItemStateChanged
       ((CardLayout)jpOperativo.getLayout()).show(jpOperativo,"carta_proveedor");
       tipo_reporte=4;
       limpiaCampos();
    }//GEN-LAST:event_jrbRequerrimientosDetalle2ItemStateChanged

    private void jtfCodSuministroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfCodSuministroActionPerformed

        if (this.jtfCodSuministro.getText().trim().length() < 1)
            this.jtfDescSuministro.requestFocus();
        else
            buscarSuministros();
}//GEN-LAST:event_jtfCodSuministroActionPerformed

    private void jtfDescSuministroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfDescSuministroActionPerformed

        buscarSuministros();
}//GEN-LAST:event_jtfDescSuministroActionPerformed

     private void buscarSuministros()
  {

    SuministroTO sumi;
    if (this.jtfCodSuministro.getText().trim().length() < 1) {

      try { sumi = (SuministroTO)this.intelliHintsSuministros.getSelectedHint();
      } catch (NullPointerException ex) {
        sumi = null;
      }
    } else {
      sumi = Listas.getSuministroCodigo(this.jtfCodSuministro.getText().trim());
    }

    if (sumi == null) {
      Utiles_MensajesDialogo.mensajeError("El suministro no existe!");
      this.jtfDescSuministro.setText("");

    } else {
      this.jtfDescSuministro.setText(sumi.toString());
      this.jtfCodSuministro.setText(sumi.getId_suministro());
      //actualizaTablaDetalles(this.pedidos_temp=getDetallesPorCriterio(sumi.getId_suministro()));
    }
  }

    private void jtfDescSuministroKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfDescSuministroKeyPressed

        if (this.jtfCodSuministro.getText().trim().length() > 0)
            this.jtfCodSuministro.setText("");
}//GEN-LAST:event_jtfDescSuministroKeyPressed

    private void jrbRequerrimientosDetalle4ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jrbRequerrimientosDetalle4ItemStateChanged
         ((CardLayout)jpOperativo.getLayout()).show(jpOperativo,"carta_suministro");
         tipo_reporte=3;
         limpiaCampos();
    }//GEN-LAST:event_jrbRequerrimientosDetalle4ItemStateChanged

    private void jrbRequerrimientos1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jrbRequerrimientos1ItemStateChanged
        ((CardLayout)jpOperativo.getLayout()).show(jpOperativo,"carta_blanco");
        tipo_reporte=1;
        limpiaCampos();
    }//GEN-LAST:event_jrbRequerrimientos1ItemStateChanged

    private void jrbRequerrimientosDetalle1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jrbRequerrimientosDetalle1ItemStateChanged
        ((CardLayout)jpOperativo.getLayout()).show(jpOperativo,"carta_blanco");
        tipo_reporte=2;
        limpiaCampos();
    }//GEN-LAST:event_jrbRequerrimientosDetalle1ItemStateChanged


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JPanel carta_blanco;
    private javax.swing.JPanel carta_licitacion;
    private javax.swing.JPanel carta_proveedor;
    private javax.swing.JPanel carta_suministro;
    private administracion.BeanBinding.CboBeanBindingEmpresa cboBeanBindingEmpresa1;
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo1;
    private administracion.BeanBinding.CboBeanBindingZona cboBeanBindingZona1;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JButton jbBuscar;
    private javax.swing.JButton jbCancelar;
    private javax.swing.JComboBox jcbEmpresa;
    private javax.swing.JComboBox jcboZona;
    private javax.swing.JFormattedTextField jftFechaDesde;
    private javax.swing.JFormattedTextField jftFechaHasta;
    private javax.swing.JPanel jpOperativo;
    private javax.swing.JRadioButton jrbCompra;
    private javax.swing.JRadioButton jrbRequerrimientos1;
    private javax.swing.JRadioButton jrbRequerrimientosDetalle1;
    private javax.swing.JRadioButton jrbRequerrimientosDetalle2;
    private javax.swing.JRadioButton jrbRequerrimientosDetalle4;
    private javax.swing.JRadioButton jrbServicio;
    private javax.swing.JTextField jtfCodSuministro;
    private javax.swing.JTextField jtfDescSuministro;
    private javax.swing.JTextField jtfLicitacion;
    private javax.swing.JTextField jtfRazon;
    private javax.swing.JTextField jtfRuc;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

    private void limpiaCampos() {
        this.jtfCodSuministro.setText("");
        this.jtfDescSuministro.setText("");
        this.jtfLicitacion.setText("");
        this.jtfRazon.setText("");
        this.jtfRuc.setText("");
        this.jftFechaDesde.setText("");
        this.jftFechaHasta.setText("");
    }

}
